#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
字符串格式化测试模块

本模块包含各种字符串格式化的测试函数，用于验证 MCPy 编译器
对字符串格式化的支持和转换能力。
"""


def test_fstring_basic() -> str:
    """基础 f-string 测试"""
    name: str = "MCPy"
    age: int = 5
    return f"Hello {name}, you are {age} years old!"


def test_fstring_expressions() -> str:
    """f-string 表达式测试"""
    x: int = 10
    y: int = 20
    return f"Sum: {x + y}, Product: {x * y}"


def test_fstring_format_spec() -> str:
    """f-string 格式说明符测试"""
    pi: float = 3.14159
    return f"Pi with 2 decimals: {pi:.2f}"


def test_str_format_basic() -> str:
    """基础 str.format 测试"""
    return "Hello {}, you are {} years old!".format("MCPy", 5)


def test_str_format_named() -> str:
    """命名参数 str.format 测试"""
    return "Hello {name}, you are {age} years old!".format(name="MCPy", age=5)


def test_str_format_mixed() -> str:
    """混合参数 str.format 测试"""
    return "Hello {}, your score is {score}".format("Alice", score=95)


def test_str_format_object() -> str:
    """命名参数 str.format 测试"""
    person: dict = {"ages": [1, 2, 3], "names": ["Alice", "Bob", "Charlie"]}
    return "Hello {names}, you are {ages} years old!".format(**person)


def test_str_format_variable() -> str:
    """变量格式字符串 str.format 测试"""
    fmt_str: str = "Hello {name}, you are {age} years old!"
    return fmt_str.format(name="MCPy", age=5)


def test_fstring_escaping() -> str:
    """f-string 转义测试"""
    value: int = 42
    return f"Value in braces: {{{value}}}"


def test_nested_set_function() -> set[tuple[int, str]]:
    """嵌套集合函数测试"""
    return {(1, "a"), (2, "b"), (3, "c")}
